package com.ruoyi.project.WebMoudle.WxShopType.service.impl;

import java.util.List;

import com.ruoyi.common.constant.WxConstant;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.WebMoudle.WxShop.domain.ShopEntity;
import com.ruoyi.project.WebMoudle.WxShop.domain.WxShop;
import com.ruoyi.project.WebMoudle.WxShop.mapper.WxShopMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.WebMoudle.WxShopType.mapper.WxShopTypeMapper;
import com.ruoyi.project.WebMoudle.WxShopType.domain.WxShopType;
import com.ruoyi.project.WebMoudle.WxShopType.service.IWxShopTypeService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 商铺类型Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-06-18
 */
@Service
public class WxShopTypeServiceImpl implements IWxShopTypeService 
{
    @Autowired
    private WxShopTypeMapper wxShopTypeMapper;

    /**
     * 查询商铺类型
     * 
     * @param id 商铺类型ID
     * @return 商铺类型
     */
    @Override
    public WxShopType selectWxShopTypeById(Long id)
    {
        return wxShopTypeMapper.selectWxShopTypeById(id);
    }

    /**
     * 查询商铺类型列表
     * 
     * @param wxShopType 商铺类型
     * @return 商铺类型
     */
    @Override
    public List<WxShopType> selectWxShopTypeList(WxShopType wxShopType)
    {
        return wxShopTypeMapper.selectWxShopTypeList(wxShopType);
    }

    /**
     * 新增商铺类型
     * 
     * @param wxShopType 商铺类型
     * @return 结果
     */
    @Override
    public int insertWxShopType(WxShopType wxShopType)
    {
        wxShopType.setCreateTime(DateUtils.getNowDate());
        return wxShopTypeMapper.insertWxShopType(wxShopType);
    }

    /**
     * 修改商铺类型
     * 
     * @param wxShopType 商铺类型
     * @return 结果
     */
    @Override
    public int updateWxShopType(WxShopType wxShopType)
    {
        wxShopType.setUpdateTime(DateUtils.getNowDate());
        return wxShopTypeMapper.updateWxShopType(wxShopType);
    }

    /**
     * 删除商铺类型对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWxShopTypeByIds(String ids)
    {
        return wxShopTypeMapper.deleteWxShopTypeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商铺类型信息
     * 
     * @param id 商铺类型ID
     * @return 结果
     */
    @Override
    public int deleteWxShopTypeById(Long id)
    {
        return wxShopTypeMapper.deleteWxShopTypeById(id);
    }

    /**
     * 校验类别名称唯一
     */
    @Override
    public String checkNameUnique(WxShopType shopType) {
        shopType.setIsOpen(WxConstant.OPEN);
        List<WxShopType> wxShopTypeList = wxShopTypeMapper.checkNameUnique(shopType);
        if (wxShopTypeList.size()>0)
        {
            return WxConstant.TYPENAME_NOT_UNIQUE;
        }
        return WxConstant.TYPENAME_UNIQUE;
    }

    /**
     * 校验序号唯一
     */
    @Override
    public String checkSortNumUnique(WxShopType shopType) {
        shopType.setIsOpen(WxConstant.OPEN);
        List<WxShopType> wxShopTypeList = wxShopTypeMapper.checkSortNumUnique(shopType);
        if (wxShopTypeList.size()>0)
        {
            return WxConstant.TYPENAME_NOT_UNIQUE;
        }
        return WxConstant.TYPENAME_UNIQUE;
    }
}
